package 剑指offer.Month7_07.day14;

public class 树的子结构 {
    public boolean HasSubtree(TreeNode root1,TreeNode root2) {
        if(root1 == null || root2 == null) return false;
        return solve(root1,root2);
    }

    public boolean solve(TreeNode root1,TreeNode root2){
        if(root2 == null){
            return true;
        }
        if(root1 == null){
            return  false;
        }
        if(root1.val == root2.val && solve(root1.left,root2.left) && solve(root1.right,root2.right)){
            return true;
        }
        return solve(root1.left,root2) || solve(root1.right,root2);
    }
}
